﻿/*

Copyright 2009 Guillaume Amringer

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/

package {
	
	import de.polygonal.ds.HashMap;
	import lt.uza.utils.Global;
	import org.papervision3d.cameras.Camera3D;
	import org.papervision3d.objects.primitives.Plane;
	import org.papervision3d.materials.ColorMaterial;
	import org.papervision3d.scenes.Scene3D;
	import vars.PlayerType;
	
	import org.papervision3d.events.InteractiveScene3DEvent;
	
	public class Game {
		
		public var globals:Global = Global.getInstance();
		
		public var gameInterface:GameInterface;
		public var players:PlayersHolder = new PlayersHolder();
		public var map:Map = new Map();
		
		public var unitsManager:UnitsManager = new UnitsManager();
		
		private var _currentPlayer:Player;
		
		
		
		public function Game(pGameInterface:GameInterface):void {
			
			//	Misc stuff
			globals.game = this;
			gameInterface = pGameInterface;
			
			//	Add players
			_currentPlayer = new Player(PlayerType.HUMAN, map.startingCoordinates.shift());
			players.addPlayer(_currentPlayer);
			players.addPlayer(new Player(PlayerType.AI, map.startingCoordinates.shift()));
			
			//	Take care of interface stuff
			gameInterface.scene = map;
			gameInterface.camera.y = 1200;
			gameInterface.camera.x = 0;
			gameInterface.camera.z = -2500;
			gameInterface.cameraInterest.copyPosition(_currentPlayer.startingPoint);
			
			
		}
		
		public function start():void {
			gameInterface.startRendering();
		}
	}
}